home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Activation
/
SubWindowFocus.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
4KB
|
168 lines
// SubWindowFocus.cp
#ifndef SubWindowFocus_h
#include "SubWindowFocus.h"
#endif
SubWindowFocus::SubWindowFocus( WindowFocus& window, AtStart )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, *this )
{
window.subFoci.Add( link, beforeStart );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window, AtEnd )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, *this )
{
window.subFoci.Add( link, afterEnd );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
Before,
SubWindowFocus& sibling )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, *this )
{
window.subFoci.Add( link, before, sibling.link );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
After,
SubWindowFocus& sibling )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, *this )
{
window.subFoci.Add( link, after, sibling.link );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
TabKeys& tabHandler,
AtStart )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, tabHandler )
{
window.subFoci.Add( link, beforeStart );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
TabKeys& tabHandler,
AtEnd )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, tabHandler )
{
window.subFoci.Add( link, afterEnd );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
TabKeys& tabHandler,
Before,
SubWindowFocus& sibling )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, tabHandler )
{
window.subFoci.Add( link, before, sibling.link );
}
SubWindowFocus::SubWindowFocus( WindowFocus& window,
TabKeys& tabHandler,
After,
SubWindowFocus& sibling )
: Focus( below, window ),
Enableable( true ),
link( this ),
siblings( window.subFoci ),
tabber( window, tabHandler )
{
window.subFoci.Add( link, after, sibling.link );
}
void SubWindowFocus::PassFocusForward()
{
for ( const ListLink<SubWindowFocus> *p = link.Next();
p != 0;
p = p->Next() )
if ( (*p)->Enabled() )
{
Parent()->FavorChild( **p );
return;
}
for ( const ListLink<SubWindowFocus> *p = siblings.First();
p != &link;
p = p->Next() )
if ( (*p)->Enabled() )
{
Parent()->FavorChild( **p );
return;
}
}
void SubWindowFocus::PassFocusBackward()
{
for ( const ListLink<SubWindowFocus> *p = link.Previous();
p != 0;
p = p->Previous() )
if ( (*p)->Enabled() )
{
Parent()->FavorChild( **p );
return;
}
for ( const ListLink<SubWindowFocus> *p = siblings.Last();
p != &link;
p = p->Previous() )
if ( (*p)->Enabled() )
{
Parent()->FavorChild( **p );
return;
}
}
void SubWindowFocus::TabForward( const KeystrokeEvent& )
{
PassFocusForward();
}
void SubWindowFocus::TabBackward( const KeystrokeEvent& )
{
PassFocusBackward();
}
void SubWindowFocus::BeEnabled()
{
if ( Parent()->FavoredChild() == 0 )
Parent()->FavorChild( *this );
}
void SubWindowFocus::BeDisabled()
{
if ( Parent()->FavoredChild() == this )
{
PassFocusForward();
if ( Parent()->FavoredChild() == this )
Parent()->FavorNoChild();
}
}